<template>
  <div class="swiper-out">
    <swiper ref="swiper">
      <swiper-item v-for="(item, index) in banners" :key="index">
        <a :href="item.link">
          <img :src="item.image" alt="" @load="swiperLoad" />
        </a>
      </swiper-item>
    </swiper>
  </div>
</template>

<script>
import { swiper, swiperItem } from "components/common/swiper";

export default {
  name: "swiperHome",
  components: {
    swiper,
    swiperItem,
  },
  props: {
    banners: {
      type: Array,
      required: true,
    },
  },
  data() {
    return {
      imgLoad: false,
    };
  },
  methods: {
    startTimer() {
      this.$refs.swiper && this.$refs.swiper.startTimer();
    },
    stopTimer() {
      this.$refs.swiper && this.$refs.swiper.stopTimer();
    },
    swiperLoad() {
      if (!this.imgLoad) {
        this.$emit("swiperImgLoad");
        this.imgLoad = true;
      }
    },
  },
};
</script>

<style scoped>
</style>